package com.real.fact.web.customer.application;

import com.globant.katari.core.application.Command;
import com.real.fact.web.customer.domain.Customer;
import com.real.fact.web.customer.domain.CustomerRepository;

public class ModifyCustomerStatusCommand implements Command<Void> {
  
  private CustomerRepository customerRepository;
  
  private long customerId;

  public ModifyCustomerStatusCommand(CustomerRepository customerRepository) {
    this.customerRepository = customerRepository;
  }
  
  public Void execute() {
    Customer customer = customerRepository.findById(customerId);
    if (customer.isActive())
      customer.setInactive();
    else
      customer.setActive();
    customerRepository.save(customer);
    return null;
  }

  public long getCustomerId() {
    return customerId;
  }

  public void setCustomerId(long customerId) {
    this.customerId = customerId;
  }
  
}
